function AddCar(){}
//主要功能是详情页上数量的加减
$.extend(AddCar.prototype,{
    init:function(num){
        this.input = $(".txts");
        this.number = this.input.val();
        $(".reduce").on("click",$.proxy(function(){
            this.reduce()
        },this))
        $(".adds").on("click",$.proxy(function(){
            this.adds()
        },this))
        this.input.on("change",$.proxy(function(){
            this.change()
        },this))
        //添加一个顶部悬浮效果
        this.box =$(".more_title");
        this.box_top = this.box.position().top;
        //添加滚动事件
        $(window).on("scroll",$.proxy(function(){
            var scrollTop = $("html,body").scrollTop();
            this.scrollTop(scrollTop);
        },this))
    },
    scrollTop : function(scrollTop){
        if(scrollTop >= this.box_top){
            this.box.css({
                position : "fixed",
                top : "50px",
                "z-index" : 10,
                "width" : "100%"
            })
        }else{
            this.box.css({
                position : "relative"
            })
        }
    },
    // 数量--
    reduce:function(){
        this.number --;
        this.number = this.number <= 1 ? 1 : this.number
        this.input.val(this.number);
    },
    //数量++
    adds:function(){
        this.number ++;
        this.input.val(this.number);
    },
    //自定义数量 
    change:function(){
        this.input.val() = this.input.val() <= 1 ? 1 : this.input.val();
        this.number = this.input.val()
    }
})
export default new AddCar();